﻿var isShownAlert = false;
function showAlert(message, error) {
    ////console.log(message, error);
    ////try {
    if (!isShownAlert) {
        var errorMessage = message + "\n" + (error === undefined ? "" : "\n" + error.status + ": " + error.statusText);
        $("#error-view .error-header").show();
        $("#error-view .message").text(errorMessage);
        $("#error-view").show().data().kendoMobileModalView.open();
        isShownAlert = true;
    }
    ////} catch (e) {
    ////    console.log(e);
    ////}
}
function showWarning(message, error) {
    ////console.log(message, error);
    ////try {
    if (!isShownAlert) {
        var errorMessage = message + "\n" + (error === undefined ? "" : "\n" + error.status + ": " + error.statusText);
        $("#error-view .error-header").show();
        $("#error-view .message").text(errorMessage);
        $("#error-view").show().data().kendoMobileModalView.open();
        isShownAlert = true;
    }
    ////} catch (e) {
    ////    console.log(e);
    ////}
}
function isOnline() {
    //return navigator.connection.type != Connection.NONE;
    return navigator.onLine;
    ////return navigator.onLine && false;
}

window.setInterval(function () {
    if (!isOnline() && !isShownAlert) {
        showAlert("No network connection available. Please try again when online.");
    }
}, 10000);
